#ifndef QIZI_H
#define QIZI_H
#include<QRect>
#include<QPainter>
#include<QString>
class qizi
{
public:
    qizi();
    ~qizi();

    enum TYPE{JIANG,CHE,PAO,MA,BING,SHI,XIANG};

    int _row;
    int _col;
    int _id;
    bool _dead;
    bool _red;
    TYPE _type;
    void init(int id){
        struct{
            int row,col;
            qizi::TYPE type;
        }pos[16]={
        {0,0,qizi::CHE},
        {0,1,qizi::MA},
        {0,2,qizi::XIANG},
        {0,3,qizi::SHI},
        {0,4,qizi::JIANG},
        {0,5,qizi::SHI},
        {0,6,qizi::XIANG},
        {0,7,qizi::MA},
        {0,8,qizi::CHE},
        {2,1,qizi::PAO},
        {2,7,qizi::PAO},
        {3,0,qizi::BING},
        {3,2,qizi::BING},
        {3,4,qizi::BING},
        {3,6,qizi::BING},
        {3,8,qizi::BING},
        };
        _id=id;
        _dead=false;
        _red=id<16;
        if(id<16){
            _row=pos[id].row;
            _col=pos[id].col;
            _type=pos[id].type;
        }
        else{
            _row=9-pos[id-16].row;
            _col=8-pos[id-16].col;
            _type=pos[id-16].type;
        }
    }

    QString getText(){
        switch(this->_type){
        case JIANG:
            return "将";
        case CHE:
            return "车";
        case PAO:
            return "炮";
        case MA:
            return "马";
        case BING:
            return "兵";
        case SHI:
            return "士";
        case XIANG:
            return "象";
        }
        return "错误";
    }
};

#endif // QIZI_H
